<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib uri="http://displaytag.sf.net" prefix="display"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<script>
function CheckCheckAll(Check_ctr) {
	chk = document.getElementsByName('selectedCategory');
	if (Check_ctr.checked == true) {
		chk.checked = true;
		for (i = 0; i < chk.length; i++) {
			chk[i].checked = true;
		}
	} else {
		chk.checked = false;
		for (i = 0; i < chk.length; i++) {
			chk[i].checked = false;
		}
	}
}

function deleteCategory() {
	var flag = false;
	chk = document.getElementsByName('selectedCategory');
	for (i = 0; i < chk.length; i++) {
		if(chk[i].checked == true) {
			flag = true;
			break;
		}
	}

	if(flag) {
		return wantToDelete('Want to delete selected categories?');
	} else {
		alert('Select at least one category to delete...');
		return false;
	}
}
</script>

<table width="100%" border="0" cellspacing="0" cellpadding="0">
	<tr>
		<td>
			<div class="blue-text16" style="margin: 0px 0px 0px 0px">
				<table width="100%">
					<tr>
						<td class="heding" align="left">
							<s:text name="lable.myfavoritecategories" />
						</td>
						<td align="left">
							<a href="addToFavorite.htm" class="common-link"><s:text name="lable.addtofavoritecategories" /></a>
						</td>
					</tr>
				</table>
			</div>
			<div class="header-separator-bg" style="margin: 10px 5px 17px 0px"></div>
			<div style="margin: 0px 0px 12px 0px">
				<s:form action="deleteMultiFavoriteCategory.htm" method="post"
					theme="simple" onsubmit="return deleteCategory()">
					<table border="0" cellpadding="0" cellspacing="0" width="100%">
						<tr>
							<td width="100%">
								<display:table name="favoritesCategoriesList" pagesize="10" requestURI="favoriteCategories.htm" id="row">
									<display:column title="<input type='checkbox' name='selectall' onclick='CheckCheckAll(this)' />" class="grid-bg common-text" style="width: 5%; text-align: center" headerClass="grid-header-bg grid-header-text-link">
										<s:checkbox id="chkBox" name="selectedCategory" theme="simple" fieldValue="%{#attr.row.id}" />
									</display:column>
									<display:column value="${row.generalCategories.categoryName}" style="width: 70%" class="grid-bg common-text" headerClass="grid-header-bg grid-header-text-link"
										autolink="true" href="browseItems.htm" paramId="cid" paramName="${row.generalCategories.categoryId}" title="Category" />
									<display:column title="Added" class="grid-bg common-text" style="width: 15%" headerClass="grid-header-bg grid-header-text-link">
										<s:date name="%{#attr.row.dateAdded}"
											format="%{#attr.row.user.dateFormat.format}" />
									</display:column>
									<display:column autolink="true" title="Options" style="width: 10%" class="grid-bg common-text" headerClass="grid-header-bg grid-header-text-link">
											<table>
											<tr>
												<td align="center" valign="top" class="grid-bg common-text" id="mddm" width="10%">
													<a class="mddm" href="#" onmouseover="mopen('<s:property value="%{#attr.row.id}"/>', this, 'common-link', 'right', 1)"
														onmouseout="mclosetime()">Select</a>
													<div style="visibility: hidden;" id="<s:property value="%{#attr.row.id}"/>"
														onmouseover="mcancelclosetime()"
														onmouseout="mclosetime()">
														<s:a href="editFavoriteCategory.htm?uid=%{#attr.row.id}">Edit</s:a>
														<s:a href="javascript: wantToDeleteWithURL('deleteFavoriteCategory.htm?uid=%{#attr.row.id}', 'Do you want to delete this category?')">Delete</s:a>
													<s:if test="#attr.row.note != null && #attr.row.note != ''">
														<s:a href="addEditNoteToFavoriteCategory.htm?fuid=%{#attr.row.id}">Edit Note</s:a>
													</s:if>
													<s:else>
														<s:a href="addEditNoteToFavoriteCategory.htm?fuid=%{#attr.row.id}">Add Note</s:a>
													</s:else>
														<a href="browseItems.htm?cid=<s:property value="%{#attr.row.id}"/>&endsoon=true">Time: ending soonest</a>
														<a href="browseItems.htm?cid=<s:property value="%{#attr.row.id}"/>&newlist=true">Time: newly listed</a>
														<a href="browseItems.htm?cid=<s:property value="%{#attr.row.id}"/>&endtoday=true">Time: ending today</a>
														<a href="browseItems.htm?cid=<s:property value="%{#attr.row.id}"/>&newtoday=true">Time: new today</a>
													</div>
												</td>
											</tr>
											</table>
									</display:column >
									<display:column>
										<tr>
											<td colspan="4" bgcolor="#ffffdd">
												<c:out value="${row.note}"></c:out>
											</td>
										</tr>
									</display:column>
								</display:table>
							</td>
						</tr>
						<tr>
							<td width="100%">
								<table border="0" cellspacing="0" cellpadding="0">
									<tr>
										<td><img src="images/middle/btn-grey-left1.gif" alt=" " width="6" height="23" /></td>
										<td class="btn-grey-middle1 "><s:submit name="delete" value="delete" align="left" theme="simple" cssClass="submit-btn-common" /></td>
										<td><img src="images/middle/btn-grey-right1.gif" alt=" " width="6" height="23" /></td>
									</tr>
								</table>
							</td>
						</tr>
					</table>
				</s:form>
			</div>
		</td>
	</tr>
</table>